package com.flappySeeker.util.baidu;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.flappySeeker.util.HttpClienTool;



public class ZHutil   {
	private static String neturl = "http://baike.baidu.com/search/word?word=";
	
	
	public static String getcontent( String keyword) {
		try {
			String url = neturl+URLEncoder.encode(keyword,"utf-8");
			String content = HttpClienTool.getResponseByGetMethod(url);
			Document doc = Jsoup.parse(content);
			
			String contentText = "";
			for(int i = 0;i<5;i++){
				contentText = contentText + doc.getElementsByClass("para").get(i).text();
			}
			for(int i = 1;i<5;i++){
				contentText = contentText.replaceAll("["+i+"]", "");
				contentText = contentText.replaceAll("'", "");
			}
			return contentText;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return "";
	}
	public static void main(String args[]) throws IOException{
		getcontent("电子科技大学");
	}
}
